/**
 * made in 2008-3-9  下午03:53:51
 * 唉 我容易吗我 
 */
package com.litxuf.logic.core.conn;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

import java.io.File;
import java.util.HashSet;
import java.util.Set;

/**
 * @author xufeng
 * 
 */
public class CreateDB {
	static Session session;
//使用之前 先创建一个空的数据库
	public static void main(String[] args) {
		Configuration config = null;
		Transaction tx = null;

		try {
			  config = new Configuration().configure();
			  System.out.println("..........");
			System.out.println("Creating tables...");
			SchemaExport schemaExport = new SchemaExport(config);
			schemaExport.create(true, true);
			System.out.println("Table created.");
			System.out.println("..........");
			SessionFactory sessionFactory = config.buildSessionFactory();
			session = sessionFactory.openSession();
			tx = session.beginTransaction();
			tx.commit();
		} catch (HibernateException e) {
			e.printStackTrace();
			try {
				tx.rollback();
			} catch (HibernateException e1) {
				e1.printStackTrace();
			}
		} finally {

		}
		
		System.out.println(".....SUCCESS.....");
	}

}
